
package com.yuan.view;

import com.yuan.application.ImageLoaderManage;
import com.yuan.graduate.R;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * 自定义属性 自定义图片下载控件
 * 
 * @author YUAN
 */
public class NetImageView extends ImageView {

    private String ImageUrl = "123";
    private TypedArray mTypedArray = null;
    Context mContext;

    public NetImageView(Context context) {
        super(context, null);
        // TODO Auto-generated constructor stub
    }

    @SuppressLint("Recycle")
    public NetImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
        mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.NetImageView);
        ImageUrl = mTypedArray.getString(R.styleable.NetImageView_ImageUrl);
        mContext = context;
        initView();
    }

    private void initView() {
        // TODO Auto-generated method stub
        if (ImageUrl == null)
            return;
        ImageLoaderManage
                .getInstance()
                .getImageLoader()
                .displayImage(ImageUrl, NetImageView.this,
                        ImageLoaderManage.getInstance().getOptions(), null);
    }

    public void setImageUrl(String ImageUrl) {
        this.ImageUrl = ImageUrl;
        initView();
    }

    public String getImageUrl() {
        return ImageUrl;
    }

}
